<template>
  <main>
    <div class="person-header">
      <div class="person-info">
        <img :src="user.avatar_url || avatar" alt="" class="avster">
        <div>
          <p class="name">{{ user.name }}</p>
          <p class="welcome">欢迎使用延长壳牌(广东)石油有限公司加油卡～</p>
        </div>
      </div>
    </div>
    <ul class="menu-card">
      <li @click="handleClick('OrderList', 1)">
        <p>待付款</p>
        <i class="iconfont icon-daifukuan"></i>
      </li>
      <li @click="handleClick('OrderList', 2, '1')">
        <p>未使用</p>
        <i class="iconfont icon-daifahuo3"></i>
      </li>
      <li @click="handleClick('OrderList', 3, '1')">
        <p>已使用</p>
        <i class="iconfont icon-dingdan1"></i>
      </li>
      <li @click="handleClick('OrderList', 5, '2')">
        <p>油卡充值</p>
        <i class="iconfont icon-youhuiquan3"></i>
      </li>
      <div class="all-order" @click="handleClick('OrderList', 0)">
        查看所有订单
        <i class="iconfont icon-Arrowrightnext"></i>
      </div>
    </ul>
    <!-- <div class="persion-card">
      <img src="~assets/images/shop.jpg" alt="" class="avster">
      <div>
        <p class="name">九歌</p>
        <span class="vip">普通会员</span>
      </div>
      <img src="~assets/images/logo.png" alt="" class="logo">
    </div> -->
    <ul class="list-box">
      <router-link class="list" to='/contact' tag="li">
        <div>
          <i class="iconfont icon-kefu"></i>
          联系我们
        </div>
        <i class="iconfont icon-arrow"></i>
      </router-link>
      <li class="list" @click="showQRcode">
        <div>
          <i class="iconfont icon-aixinxiantiao"></i>
          关注我们
        </div>
        <i class="iconfont icon-arrow"></i>
      </li>
      <li class="list" @click="handleClick('Setting')">
        <div>
          <i class="iconfont icon-shezhi3"></i>
          设置
        </div>
        <i class="iconfont icon-arrow"></i>
      </li>
    </ul>
    <van-overlay :show="isShow" @click="showQRcode">
      <div class="wrapper" @click.stop>
        <img src="~assets/images/qrcode.jpg" alt="">
      </div>
    </van-overlay>
  </main>
</template>

<script>
import { mapActions, mapGetters } from 'vuex'

export default {
  name: 'personal',
  data() {
    return {
      avatar: require('assets/images/avatar.png'),
      isShow: false,
    }
  },
  computed: {
    ...mapGetters(['user']),
  },
  created() {
    this.$emit('showTabMenu', true);
  },
  methods: {
    ...mapActions([
      'OrderTabIndex',
      'SetOrderType'
    ]),
    handleClick (url, index, order_type) {
      this.OrderTabIndex(index)
      order_type && this.SetOrderType(order_type)
      this.$router.push({name: url})
    },
    showQRcode() {
      this.isShow = !this.isShow
    }
  }
}
</script>

<style lang="less" scoped>
.person-header{
  height: 200px;
  background: url('~assets/images/personal-bg1.jpg') no-repeat;
  background-size: 100%;
  .person-info{
    display: flex;
    align-items: center;
    padding: 40px 30px 0 30px;
    color: #fff;
    .avster{
      width: 70px;
      height: 70px;
      border-radius: 100px;
      border: 3px solid #96bfd6;
      margin-right: 15px;
    }
    .name{
      margin-bottom: 10px;
    }
    .welcome{
      font-size: 14px;
    }
  }
}
.menu-card{
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: auto 40px;
  gap: 10px 0;
  padding: 20px 0 0;
  border-radius: 8px;
  background: #fff;
  margin: 20px;
  margin-top: -30px;
  font-size: 14px;
  // height: 80px;
  box-shadow: 2px 2px 10px #ddecf3;
  text-align: center;
  li{
    // border-right: 1px solid #f5f5f5;
    p{
      padding-bottom: 10px;
      font-weight: bold;
    }
    i{
      font-size: 30px;
    }
  }
}
.persion-card{
  position: relative;
  padding: 20px 15px;
  margin: 0 15px 15px;
  display: grid;
  grid-template-columns: 70px auto 80px;
  grid-template-rows: auto;
  gap: 10px;
  border-radius: 10px;
  box-shadow: 2px 2px 10px #eee;
  background: #fbeec6;
  font-size: 14px;
  .avster{
    width: 60px;
    height: 60px;
    border-radius: 100px;
    border: 3px solid #fff;
  }
  .logo{
    width: 1.8rem;
    opacity: 0.2;
    position: absolute;
    right: 0;
    bottom: 0;
  }
  .name{
    margin-bottom: 10px;
  }
  .vip{
    background: #FF9800;
    border-radius: 10px;
    color: #fff;
    font-size: 12px;
    padding: 2px 10px;
    margin-top: 20px;
  }
}
.list-box{
  background: #fff;
  padding-left: 20px;
  box-shadow: 2px 0px 10px #eee;
  .list{
    line-height: 1rem;
    border-bottom: 0.02rem solid #eee;
    font-size: 15px;
    display: flex;
    justify-content: space-between;
    padding-right: 15px;
    &:last-child{
      border-bottom: none;
    }
    .icon-arrow{
      color: #aaa;
    }
  }
}
.all-order{
  grid-column-start: 1;
  grid-column-end: 5;
  border-top: 1px solid #f5f5f5;
  font-size: 12px;
  align-items: center;
  display: flex;
  justify-content: center;
  i{
    color: #ff236e;
    font-weight: 300;
    margin-left: 10px;
  }
}
.van-overlay{
  background-color: rgba(0,0,0,.4);
  z-index: 100;
  display: flex;
}
.wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 240px;
  margin: auto;
  height: 240px;
  img{
    width: 100%;
  }
}

</style>
